<template>
  <div>
    <el-card>
      <el-breadcrumb separator=">">
        <el-breadcrumb-item>订单管理</el-breadcrumb-item>
        <el-breadcrumb-item :to="{ path: '/home/order' }"
          >订单查询</el-breadcrumb-item
        >
        <el-breadcrumb-item>订单详细</el-breadcrumb-item>
      </el-breadcrumb>
      <h1>订单详细</h1>
    </el-card>
    <el-card class="top">
      <el-row>
        <el-col :span="4">
          <p>等待商家发货</p>
        </el-col>
        <el-col :span="1">
          <el-button type="primary" @click="faHuo">去发货</el-button>
        </el-col>
        <el-col>
          <!-- <el-steps :active="1">
            <el-step title="步骤1" description="描述性文字"></el-step>
            <el-step title="步骤2" description="描述性文字"></el-step>
            <el-step title="步骤3" description="描述性文字"></el-step>
            <el-step title="步骤4" description="描述性文字"></el-step>
          </el-steps>-->
        </el-col>
      </el-row>
    </el-card>
    <el-card class="center">
      <el-row>
        <el-col :span="8">
          <el-form label-width="80px" :model="userForm" class="user">
            <el-form-item>
              <el-row class="center-title">
                <el-col :span="10">
                  <span>收货人信息</span>
                </el-col>
                <el-col :span="4">
                  <span
                    style="color: blue; cursor: pointer"
                    @click="taggleDialog"
                    >编辑</span
                  >
                </el-col>
              </el-row>
            </el-form-item>
            <el-form-item v-model="userForm.userName">
              <el-row>
                <el-col :span="8">
                  <span>收货人姓名:</span>
                </el-col>
                <el-col :span="16">
                  <span>{{ userForm.userName }}</span>
                </el-col>
              </el-row>
            </el-form-item>
            <el-form-item v-model="userForm.userPhone">
              <el-row>
                <el-col :span="6">
                  <span>联系人电话:</span>
                </el-col>
                <el-col :span="18">
                  <span>{{ userForm.userPhone }}</span>
                </el-col>
              </el-row>
            </el-form-item>
            <el-form-item v-model="userForm.address">
              <el-row>
                <el-col :span="6">
                  <span>收货地址:</span>
                </el-col>
                <el-col :span="18">
                  <span>{{ userForm.address }}</span>
                </el-col>
              </el-row>
            </el-form-item>
            <el-form-item>
              <el-row>
                <el-col :span="6">
                  <span>买家留言:</span>
                </el-col>
                <el-col :span="18">
                  <span>{{ userForm.message }}</span>
                </el-col>
              </el-row>
            </el-form-item>
          </el-form>
        </el-col>
        <el-col :span="8">
          <el-row>
            <el-form :model="orderForm" label-width="80px" class="user">
              <el-form-item>
                <el-col>
                  <span style="font-size: 20px">订单信息</span>
                </el-col>
              </el-form-item>
              <el-form-item>
                <el-col :span="6">
                  <span>订单编号:</span>
                </el-col>
                <el-col :span="18">
                  <span>{{ orderForm.id }}</span>
                </el-col>
              </el-form-item>
              <el-form-item>
                <el-col :span="6">
                  <span>下单时间:</span>
                </el-col>
                <el-col :span="18">
                  <span>{{ orderForm.created }}</span>
                </el-col>
              </el-form-item>
              <el-form-item>
                <el-col :span="6">
                  <span>支付时间:</span>
                </el-col>
                <el-col :span="18">
                  <span>{{ orderForm.payCreated }}</span>
                </el-col>
              </el-form-item>
              <el-form-item>
                <el-col :span="6">
                  <span>支付方式:</span>
                </el-col>
                <el-col :span="18">
                  <span>{{ orderForm.payWay }}</span>
                </el-col>
              </el-form-item>
              <el-form-item>
                <el-col :span="6">
                  <span>订单类型:</span>
                </el-col>
                <el-col :span="18">
                  <span>{{ orderForm.type }}</span>
                </el-col>
              </el-form-item>
              <el-form-item>
                <el-col :span="6">
                  <span>订单来源:</span>
                </el-col>
                <el-col :span="18">
                  <span>{{ orderForm.source }}</span>
                </el-col>
              </el-form-item>
              <el-form-item v-model="orderForm.count">
                <el-col :span="6">
                  <span>订单备注:</span>
                </el-col>
                <el-col :span="1">
                  <span>{{ orderForm.count }}</span>
                </el-col>
                <el-col :span="14" :offset="1">
                  <span
                    style="color: blue; cursor: pointer"
                    @click="noteBounced"
                    >编辑备注</span
                  >
                </el-col>
              </el-form-item>
            </el-form>
          </el-row>
        </el-col>
        <el-col :span="8">
          <el-row>
            <el-form
              ref="form"
              :model="buyersForm"
              label-width="80px"
              class="user"
            >
              <el-form-item>
                <el-col :span="7">
                  <span>买家信息</span>
                </el-col>
                <!-- <el-col :span="17"
                  ><router-link
                    tag="span"
                    to="/home/detail"
                    style="cursor: pointer; color: blue"
                    >查看资料</router-link
                  ></el-col
                >-->
              </el-form-item>
              <el-form-item>
                <el-col :span="6">
                  <span>微信昵称:</span>
                </el-col>
                <el-col :span="18">
                  <span>{{ buyersForm.user }}</span>
                </el-col>
              </el-form-item>
              <el-form-item>
                <el-col :span="6">
                  <span>会员姓名:</span>
                </el-col>
                <el-col :span="18">
                  <span>{{ buyersForm.name }}</span>
                </el-col>
              </el-form-item>
              <el-form-item>
                <el-col :span="6">
                  <span>会员性别:</span>
                </el-col>
                <el-col :span="18">
                  <span>{{ buyersForm.sex }}</span>
                </el-col>
              </el-form-item>
              <el-form-item>
                <el-col :span="6">
                  <span>会员年龄:</span>
                </el-col>
                <el-col :span="18">
                  <span>{{ buyersForm.age }}</span>
                </el-col>
              </el-form-item>
              <el-form-item>
                <el-col :span="6">
                  <span>会员手机:</span>
                </el-col>
                <el-col :span="18">
                  <span>{{ buyersForm.phone }}</span>
                </el-col>
              </el-form-item>
              <el-form-item>
                <el-col :span="6">
                  <span>会员卡号:</span>
                </el-col>
                <el-col :span="18">
                  <span>{{ buyersForm.card }}</span>
                </el-col>
              </el-form-item>
              <el-form-item>
                <el-col :span="7">
                  <span>成为会员时间:</span>
                </el-col>
                <el-col :span="17">
                  <span>{{ buyersForm.created }}</span>
                </el-col>
              </el-form-item>
              <el-form-item>
                <el-col :span="7">
                  <span>最近登录时间:</span>
                </el-col>
                <el-col :span="17">
                  <span>{{ buyersForm.payCreated }}</span>
                </el-col>
              </el-form-item>
            </el-form>
          </el-row>
        </el-col>
      </el-row>
    </el-card>
    <!-- <el-card class="foot">
      <el-row>
        <el-col>商品信息</el-col>
        <el-col>
          <el-table
            :data="tableData"
            style="width: 100%"
            :header-cell-style="{ background: '#eef1f6', color: '#606266' }"
          >
            <el-table-column prop="date" label="日期" width="180">
            </el-table-column>
            <el-table-column prop="name" label="姓名" width="180">
            </el-table-column>
            <el-table-column prop="address" label="地址"> </el-table-column>
          </el-table>
        </el-col>
        <el-col>
          <el-row>
            <el-col :span="17">本单积分：<span>270</span></el-col>
            <el-col :span="7">
              <el-row>
                <el-col>商品总价:<span>￥300.00</span></el-col>
                <el-col>运费:<span>￥300.00</span></el-col>
                <el-col>优惠:<span>￥30.00</span></el-col>
                <el-col></el-col>
                <el-col>本单实收:<span>￥270.00</span></el-col>
              </el-row>
            </el-col>
          </el-row>
        </el-col>
        <el-col
          ><el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="currentPage4"
            :page-sizes="[100, 200, 300, 400]"
            :page-size="100"
            layout="total, sizes, prev, pager, next, jumper"
            :total="400"
          >
          </el-pagination
        ></el-col>
      </el-row>
    </el-card>-->
    <!-- 发货框 -->
    <el-dialog
      title="提示"
      :visible.sync="dialogVisible"
      width="30%"
      :before-close="handleClose"
    >
      <el-form label-width="80px" :model="sizeForm">
        <el-form-item label="订单编号:" prop="id">
          <p>{{ sizeForm.id }}</p>
        </el-form-item>
        <el-form-item label="下单时间:" prop="created">
          <p>{{ sizeForm.created }}</p>
        </el-form-item>
        <el-form-item label="支付时间:" prop="payCreated">
          <p>{{ sizeForm.payCreated }}</p>
        </el-form-item>
        <el-form-item label="发货方式:" prop="resource">
          <el-radio-group v-model="sizeForm.resource">
            <el-radio label="物流发货"></el-radio>
            <el-radio label="无需物流"></el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="快递公司:" prop="region">
          <el-select placeholder="请输入物流公司" v-model="sizeForm.region">
            <el-option label="区域一" value="shanghai"></el-option>
            <el-option label="区域二" value="beijing"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="快递单号:" prop="courierNumber">
          <el-input v-model="sizeForm.courierNumber"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="addOrder">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 编辑收货人信息框 -->
    <el-dialog title="修改收货人信息" width="30%" :visible.sync="editorDialog">
      <el-form label-position="right" label-width="100px" :model="editForm">
        <el-form-item label="收货人姓名:" prop="userName">
          <el-input v-model="editForm.userName"></el-input>
        </el-form-item>
        <el-form-item label="联系电话:" prop="userPhone">
          <el-input v-model="editForm.userPhone"></el-input>
        </el-form-item>
        <el-form-item label="收货地址:" prop="address">
          <el-input v-model="editForm.address"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="editorDialog = false">取 消</el-button>
        <el-button type="primary" @click="queRen">确 定</el-button>
      </div>
    </el-dialog>
    <!-- 编辑备注 -->
    <el-dialog title="修改订单备注" width="30%" :visible.sync="noteDialog">
      <el-form label-position="right" label-width="100px" :model="editNoteForm">
        <el-form-item label="订单备注:">
          <el-input v-model="editNoteForm.count"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="editorDialog = false">取 消</el-button>
        <el-button type="primary" @click="noteDialog = false">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
export default {
  data() {
    return {
      // tableData: [
      //   {
      //     date: "2016-05-02",
      //     name: "王小虎",
      //     address: "上海市普陀区金沙江路 1518 弄",
      //   },
      //   {
      //     date: "2016-05-04",
      //     name: "王小虎",
      //     address: "上海市普陀区金沙江路 1517 弄",
      //   },
      //   {
      //     date: "2016-05-01",
      //     name: "王小虎",
      //     address: "上海市普陀区金沙江路 1519 弄",
      //   },
      //   {
      //     date: "2016-05-03",
      //     name: "王小虎",
      //     address: "上海市普陀区金沙江路 1516 弄",
      //   },
      // ],
      // currentPage1: 5,
      // currentPage2: 5,
      // currentPage3: 5,
      // currentPage4: 4,
      //发货弹框数据
      sizeForm: {
        id: 302020200220220,
        created: "2019-09-09 10:40",
        payCreated: "2019-09-09 10:40",
        resource: "",
        region: "",
        courierNumber: "",
      },
      // 显示隐藏发货弹框
      dialogVisible: false,
      noteDialog: false,
      //收货人信息
      userForm: {},
      //编辑弹框数据
      editForm: {
        userName: "",
        userPhone: "",
        address: "",
      },
      //显示隐藏编辑弹框
      editorDialog: false,
      editNoteForm: {
        count: "",
      },
      //备注
      orderForm: {},
      buyersForm: {},
    };
  },
  methods: {
    // handleSizeChange(val) {
    //   console.log(`每页 ${val} 条`);
    // },
    // handleCurrentChange(val) {
    //   console.log(`当前页: ${val}`);
    // },
    async faHuo() {
      this.dialogVisible = true;
      const { data: res } = await this.$axios.get("/vip/orders/findId", {
        params: {
          id: this.$route.query.id,
        },
      });
      console.log(res.data);
      this.sizeForm = {
        id: res.data.id,
        created: res.data.created,
        payCreated: "2019-09-09 10:40",
      };
    },
    ran(n, m) {
      return Math.floor(Math.random() * (m - n) + n);
    },
    async addOrder() {
      this.dialogVisible = false;
      const { data: res } = await this.$axios.post("/vip/orders/update", {
        id: ran(40, 10000000),
        created: this.sizeForm.created,
        payCreated: "2019-09-09 10:40",
        source: this.sizeForm.resource,
        num: this.sizeForm.courierNumber,
        type: this.sizeForm.region,
      });
      if (res.code != 0) return this.$message.warning("添加失败");
      this.$message.success("成功");
    },
    taggleDialog() {
      this.editorDialog = true;
      this.editForm = { ...this.userForm };
    },
    //发货弹框
    handleClose(done) {
      this.$confirm("确认关闭？")
        .then((_) => {
          done();
        })
        .catch((_) => {});
    },
    noteBounced() {
      this.noteDialog = true;
      this.editNoteForm = { ...this.orderForm };
    },
    async queRen() {
      this.editorDialog = false;
      const { data: res } = await this.$axios.post("/vip/orders/update", {
        id: this.$route.query.id,
        consignee: this.editForm.userName,
        consigneePhone: this.editForm.userPhone,
        address: this.editForm.address,
      });
      if (res.code != 0) return this.$message.warning("错误");
      this.$message.success("成功");
    },
    async getList() {
      const { data: res } = await this.$axios.get("/vip/orders/findId", {
        params: {
          id: this.$route.query.id,
        },
      });
      // console.log(res.data);
      this.userForm = {
        userName: res.data.consignee,
        userPhone: res.data.consigneePhone,
        address: res.data.address,
        message: res.data.message,
      };
      this.orderForm = {
        id: res.data.id,
        created: res.data.created,
        payCreated: "2019-09-09 10:40",
        payWay: res.data.payWay,
        type: res.data.type,
        source: res.data.source,
        count: "无",
      };
      this.buyersForm = {
        user: "小王子",
        name: "曲筱筱",
        sex: "女",
        age: 23,
        phone: "13345556666",
        card: "1235",
        created: "2019-09-09 10:40",
        payCreated: "2019-09-09 10:40",
      };
    },
  },
  created() {
    this.getList();
  },
};
</script>
<style lang="less" scoped>
.user {
  /deep/.el-form-item__content {
    font-size: 18px !important;
  }
  .el-form-item {
    margin-bottom: 0px;
  }
}

.el-card {
  margin-bottom: 20px;
}
.top {
  // height: 197px;
  // overflow: hidden;
  p {
    font-size: 24px;
    height: 40px;
    line-height: 40px;
  }
  .el-col:last-child {
    margin-top: 40px;
  }
}
.center {
  .el-row {
    > .el-col {
      margin-bottom: 10px;
    }
  }

  .center-title {
    .el-col:first-child {
      font-size: 20px;
    }
    .el-col:last-child {
      line-height: 40px;
      font-size: 20px;
      color: blue;
    }
  }
}
.foot {
  .el-pagination {
    text-align: end;
    margin-top: 0px;
  }
  .el-col {
    margin-bottom: 10px;
  }
}
</style>